package taskit.gui;

import java.util.TimerTask;

import taskit.logic.ParserReturnObject;

//@author A0098710B
class GUITimer extends TimerTask 
{
	int indexOfLastAddedDDSchedule;
	double vValueScrollPaneDDSchedule;
	
	public GUITimer(int indexOfLastAddedDDSchedule) {
		this.indexOfLastAddedDDSchedule = indexOfLastAddedDDSchedule;
		try {
			if(indexOfLastAddedDDSchedule>((GUIController.accordionDDScheduleR.getPanes().size()-1)/2)) {
				vValueScrollPaneDDSchedule = ((double)GUIController.cumulHeightPanesDDScheduleMin.get(indexOfLastAddedDDSchedule)/GUIController.anchorPaneDDScheduleR.getPrefHeight());
			} else {
				vValueScrollPaneDDSchedule = ((double)GUIController.cumulHeightPanesDDScheduleMax.get(indexOfLastAddedDDSchedule)/GUIController.anchorPaneDDScheduleR.getPrefHeight());	
			}
		} catch(Exception ex) {
			vValueScrollPaneDDSchedule = 0.5;
		}
	}
	
	public GUITimer() {
		vValueScrollPaneDDSchedule = 1.0;
	}
	
	public void run() 
	{
		if(ParserReturnObject.isDeadlineListChanged()){
		GUIController.scrollPaneDDScheduleR.setVvalue(vValueScrollPaneDDSchedule);}
		if(ParserReturnObject.isFloatingListChanged()){
		GUIController.scrollPaneFloatR.setVvalue(1.0);}
	}
}